//
//  LocalizableUitl.swift
//  Kool Car
//
//  Created by huangweiqiang on 2021/12/16.
//

import UIKit

enum AppLanguage: String {
    case english = "en"
    case chinese_simple = "zh-Hans"
    case chinese_hk = "zh-HK"
    var code: String {
        return rawValue
    }
}

class LocalizableUitl {
    static let shared = LocalizableUitl()
    public static func setLaunguageText(key: String) -> String {
        let bundle = LocalizableUitl.shared.getLaunguageBundle()
        let launguage = bundle.localizedString(forKey: key, value: nil, table: nil)
        return launguage
    }
    
    private func getLaunguageBundle() -> Bundle {
        var launguage = XTManageCenter.getLocalStringDataValue(aKey: UtilCenter.kAppLanguage) //launguage
        guard let path = Bundle.main.path(forResource: launguage, ofType: "lproj") else {
            let temp = Bundle.main.path(forResource: "zh-HK", ofType: "lproj")
            return Bundle.init(path: temp!)!
        }
        return Bundle.init(path: path)!
    }
}

